# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
import os
import urllib.request

class SasaonePipeline(object):

    def process_item(self, item, spider):
        file_path = item['file_path']
        img_name = item['img_name']
        detail_pictures = item['detail_pictures']

        file_path = os.path.join(file_path, img_name)
        file_bool = os.path.exists(file_path)
        if file_bool == False:
            urllib.request.urlretrieve(detail_pictures, file_path)

